package at.fhj.antesk.steamvaluecalc.data;

import java.util.List;

import org.apache.commons.lang3.builder.CompareToBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

public class Game implements Comparable<Game> {

    private String id;
    private String name;
    private String logo;
    private String storeLink;
    private Double hoursOnRecord;
    private List<Price> hourValues;
    private List<Price> prices;

    public Game() {
    }

    public Game(String id) {
        super();
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public String getStoreLink() {
        return storeLink;
    }

    public void setStoreLink(String storeLink) {
        this.storeLink = storeLink;
    }

    public Double getHoursOnRecord() {
        return hoursOnRecord;
    }

    public void setHoursOnRecord(Double hoursOnRecord) {
        this.hoursOnRecord = hoursOnRecord;
    }

    public List<Price> getHourValues() {
        return hourValues;
    }

    public void setHourValues(List<Price> hourValues) {
        this.hourValues = hourValues;
    }

    public List<Price> getPrices() {
        return prices;
    }


    public void setPrices(List<Price> prices) {
        this.prices = prices;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder()//
            .append(this.logo)//
            .append(this.storeLink)//
            .append(this.hoursOnRecord)//
            .append(this.hourValues)//
            .hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Game)) {
            return false;
        }

        Game otherGame = (Game)obj;
        return new EqualsBuilder() //
            .append(this.id, otherGame.id) //
            .isEquals();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this) //
            .append("id", id) //
            .append("name", name) //
            .append("logo", logo) //
            .append("storeLink", storeLink) //
            .append("hoursOnRecord", hoursOnRecord) //
            .append("hourValue", hourValues) //
            .append("prices", prices) //
            .toString();
    }

    public int compareTo(Game otherGame) {
        return new CompareToBuilder() //
            .append(this.id, otherGame.id) //
            .append(this.name, otherGame.name) //
            .append(this.logo, otherGame.logo) //
            .append(this.storeLink, otherGame.storeLink) //
            .append(this.hoursOnRecord, otherGame.hoursOnRecord) //
            .append(this.hourValues, otherGame.hourValues) //
            .toComparison();
    }

}
